
package hasthi.wsdm;

import hasthi.common.BaseContext;
import hasthi.common.HasthiException;
import hasthi.common.ManagementNotifier;
import hasthi.common.constants.WSDMConstants.SystemState;

import java.util.List;

import javax.xml.namespace.QName;


/**
 * This interface provides Management framework with access to the system. Integrating the management Adaptor to some 
 * service is essentially implementing this interface. 
 * @author hperera
 *
 */
public interface ManagedSystemHandle {
    public void init(ManagementAgentContext agentContext)throws HasthiException;
     
    public QName getResourceName();
    
    public String getDescription();
    
    public List<String> getSupportedCapabilities();
    
    /**
     * These are properties of current resource and the Capabilities are initialized using this properties
     * @return
     */
    public BaseContext getBaseContext(); 
//    /**
//     * This will be called by WSDM implementation to add the properties found in configuration file to system handle, additionally
//     * implementation of system handle may have own properties
//     * @param newProperties
//     */
//    public void init(Map<QName,Object> newProperties)throws HasthiException;
    
    public SystemState getCurrentSystemState();
    public SystemState[] getLastStateTransition();
    
    /**
     * Change the configuration of this Managed resource. The Implementation of this interface should link the 
     * change of configuration to real resource 
     * @param name
     * @param String
     */
    public List<QName> getSupportedConfigurationNames();
    public void setConfiguration(QName name,Object String)throws HasthiException;
    public Object getConfiguration(QName name)throws HasthiException;
    
    /**
     * Difference between matrics and Configurations is that matrics are send to the manager with heartbeat messages and 
     * configurations are not. Also matrics are not editable.
     * @return
     */
    public List<QName> getSupportedMatrics();
    public Object getMatric(QName name)throws HasthiException;
    
    
    
    public ManagementNotifier getNotifier();
    
    public String getSystemEndPoint();
    
    /**
     * Shutdown this resource
     * @throws HasthiException 
     */
    public void shutDown() throws HasthiException;
    
    /**
     * If health check capability is enabled, it will run a test once 30 heartbeat intervals. With default 30s epoch time that is 
     * once every 15 minutes. Users may check with in the code and not run the test, if a request has been processed with in last 15 minutes. 
     * @return
     */
    public SystemState runResourceHealthCheck();
 }

